﻿@model EvinceUI.Models.ChangePasswordModel
@{
    var message = ViewBag.Message;
    var info = Session["EmployeeData"] as EvincePayroll.Data.EmployeeData;
    if (info.UserRoleString == "Admin")
    {
        Layout = "~/Views/Shared/_Layout_Admin.cshtml";
    }
    else
    {
        Layout = "~/Views/Shared/_Layout_Employee.cshtml";
    }  
}
<script type="text/javascript">
    $(document).ready(function () {
        $('#passwordForm').submit(function () {
            var errorFlag = false;
            $('.requiredField').each(function () {
                if ($(this).val() == '') {
                    if ($(this).prev().attr('class') != 'error') {
                      //  $(this).before('<span class="error">Required Field</span>');

                    }
                    $(this).css({
                        border: '1px solid red'
                    });
                    errorFlag = true;
                } else {
                    if ($(this).prev().attr('class') == 'error') {
                        $(this).prev().remove();
                        $(this).removeAttr('style');
                    }
                }
            });
            if (errorFlag == true) {

                return false;
            }
        });

    });


</script>

@using (Html.BeginForm("ChangePassword", "Account", FormMethod.Post, new { id="passwordForm"}))
{
<div class="grid_10">
        <div class="box round first">
            <h2>Change Password</h2>
            @if (message == "Success")
            {
                <br />
            <div class="message success">
                                <h5>Success!</h5>
                                <p>
                                    Password has been changed successfully.
                                </p>
                            </div>
            }
            @if (message == "Failed")
            {
                <br />
                            <div class="message error">
                                <h5>Error!</h5>
                                <p>
                                    Password change failed, try again.
                                </p>
                            </div>
            }
<fieldset>
    <legend></legend>

    <div class="editor-label">
        @Html.Label("Enter the Old password")
    </div>
    <div class="editor-field">
       
       @Html.PasswordFor(m => m.OldPassword, new { @class = "requiredField" })
    </div>

    <div class="editor-label">
        @Html.Label("Enter New Password")
    </div>
    <div class="editor-field">
        @Html.PasswordFor(m => m.NewPassword, new { @class = "requiredField" })
    </div>
     <div class="editor-label">
        @Html.Label("Confirm Your Password")
    </div>
    <div class="editor-field">
       @* <input type ="password" id="confirmpass" name="confirmpass" runat="server" class="requiredField" />*@
        @Html.PasswordFor(m => m.ConfirmPassword, new {@class="requiredField" })
    </div>



    <p>
        <input type="submit" value="Save" />
    </p>
</fieldset>


</div></div>
}
